package com.example.drainage.ui.certupload

import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.drainage.R
import com.example.drainage.ui.certupload.dataview.DataSpotBean
import com.example.drainage.ui.certupload.dataview.SingleSelectRecyclerDataSpot

/**
 * @author 创建人 ：yanghaozhang
 * @version 1.0
 * @package 包名 ：com.example.armmvvm.ui.certupload
 * @createTime 创建时间 ：2021/12/20
 * @modifyBy 修改人 ：
 * @modifyTime 修改时间 ：
 * @modifyMemo 修改备注：
 */
class ItemCheckAdapter : SingleSelectRecyclerDataSpot.SingleSelectRecyclerAdapter(R.layout.item_cert_supervision_single_check_item) {
    override fun convert(holder: BaseViewHolder, item: DataSpotBean) {
        holder.itemView.apply {
            isSelected = holder.absoluteAdapterPosition == selectIndex
            setOnClickListener {
                if (selectIndex != holder.absoluteAdapterPosition) {
                    selectIndex = holder.absoluteAdapterPosition
                    notifyDataSetChanged()
                }
            }
        }
        holder.setText(R.id.itemName, item.text)
    }
}